﻿
Partial Class Apps_report_stp_department
    Inherits System.Web.UI.Page

    Protected Sub btnFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFilter.Click

        Try

            'ddlStatus.SelectedValue, _
            'HttpUtility.UrlEncode(ddlStatus.SelectedItem.Text)
            '&department_status={2}
            '&str_department_status={5}


            'department_status={2}&
            '&str_department_status={5}
            'ddlStatus.SelectedValue, _
            ', _HttpUtility.UrlEncode(ddlStatus.SelectedItem.Text)

            Dim lstDepString As String = ""
            Dim i As Integer
            Dim subString As String = ""

            For i = 0 To lstStpDepartment.Items.Count - 1
                If lstStpDepartment.Items(i).Selected Then
                    lstDepString += lstStpDepartment.Items(i).Value + ","
                End If
            Next

            If lstDepString = "" Then
                subString = "0"
            Else
                subString = lstDepString.Substring(0, lstDepString.Length - 1)
            End If


            '&str_department_code={3}
            'ddlDepartment.SelectedValue
            ', _HttpUtility.UrlEncode(ddlDepartment.SelectedItem.Text)
            '//   Dim url = "../Reports/report_stp_department.aspx?department_code={1}&master_department_code={0}&str_master_department_level={2}"
            Dim url = "../Reports/report_stp_department2.aspx?department_code={1}&master_department_code={0}&str_master_department_level={2}"
            url = String.Format(url, _
                                ddlDepartmentMaster.SelectedValue, _
                                subString, _
                                HttpUtility.UrlEncode(ddlDepartmentMaster.SelectedItem.Text))

            Dim script = String.Format(" window.open('{0}','_blank');", url)

            ScriptManager.RegisterStartupScript( _
            Me, _
            Me.GetType(), _
            Guid.NewGuid().ToString(), _
            script, _
            True _
            )
        Catch ex As Exception
            GenericHelper.ShowAlert(Me, ex.Message)
        End Try

    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Try
            'lstStpDepartment.Items.Item(0).Value = 0
            'lstStpDepartment.Items.Item(0).Text = "ทั้งหมด"
        Catch ex As Exception
            GenericHelper.ShowAlert(Me, ex.Message)
        End Try

    End Sub

    Protected Sub Page_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete
        Dim BreadCrumpBG As HtmlControl = Page.Master.FindControl("tdBreadCrump")
        Dim BreadCrump As Literal = Page.Master.FindControl("ltrBreadCrump")
        CodeMatrix.Business.GenericData.SetBreadCrump(BreadCrumpBG, BreadCrump, 51)
    End Sub
End Class
